package com.douwong.student.popuwindow;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;

import com.bumptech.glide.Glide;
import com.douwong.student.R;
import com.douwong.student.rxjava.EndPointInterface;
import com.douwong.student.utils.ScreenUtils;
import com.douwong.student.view.ScaleImageView;

public class ImageUrlShowPopu extends PopupWindow {

	private ScaleImageView img;
	private View view;
	private Context mContext;

	public ImageUrlShowPopu(Context context, String url) {
		mContext = context;
		LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		view=inflater.inflate(R.layout.image_show, null);
		initView(url);
	}


	void initView(String url){
		img=(ScaleImageView) view.findViewById(R.id.img);
		Glide.with(mContext).load(EndPointInterface.HEAD_PIC+url).override(ScreenUtils.getScreenWidth(),ScreenUtils.getScreenHeight()).into(img);

		img.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		this.setContentView(view);
		this.setWidth(LayoutParams.MATCH_PARENT);
		this.setHeight(LayoutParams.MATCH_PARENT);
		// 设置SelectPicPopupWindow弹出窗体可点击
		this.setFocusable(true);
		ColorDrawable dw = new ColorDrawable(0xffffff);
		this.setBackgroundDrawable(dw);



	}

	/**
	 * 设置显示图片
	 * @param url
	 */
	public void setImageView(String url){
		Glide.with(mContext).load(EndPointInterface.HEAD_PIC+url).into(img);
	}
}
